import { ref } from 'vue';
import { getGlobalOlMap } from "@/components/GlobalOlMap";
import { addPointDataLayer } from 'gmap-ol';;
import markIcon from '@/assets/icon/mark_bs.png';

const globalMap = ref<any>(null);
// 添加需要的地图数据
export const addMapData = async (infoData) => {
  globalMap.value = getGlobalOlMap();
  const view = globalMap.value.getView();

  view.animate({
    zoom: 13,
    center: [Number(infoData?.lgtd), Number(infoData?.lttd)]
  });

  const pointOptions = {
    layerName: 'mark_PointLayer',
    icon: markIcon,
    zIndex: 1000,  // 非必填
    styles: {
      image: {
        scale: 0.6,
        anchor: [0.5, 0.95], // 锚点设置为图标底部中心
      },
    },
  };
  // 把数据加载在地图上
  addPointDataLayer(globalMap.value, [infoData], pointOptions);
}
